using System;
using System.Reflection;
using BSpec.Specification;
using BSpec.Specs;
using NUnit.Framework;

namespace specification_dataset_specs
{
    namespace with_scenario_of
    {
        public abstract class building_a_specification_dataset : SpecificationBase<SpecificationDataSet>
        {
            protected override void setup_scenario()
            {
            }

            protected override SpecificationDataSet create_subject()
            {
                return SpecificationDataSet.Build(Assembly.GetExecutingAssembly());
            }

            protected override void execute_scenario()
            {
            }
        }
    }

    namespace given_the_specification_dataset_is_built_from_an_assembly
    {
        [TestFixture]
        public class when_building : with_scenario_of.building_a_specification_dataset
        {
            [Test]
            public void should_add_all_concerns_found_in_the_assembly()
            {
                the_subject.Concerns.should_not_be_empty();
            }
        }
    }

    namespace given_the_specification_dataset_contains_concerns
    {
        [TestFixture]
        public class when_adding_a_concern_that_already_exists : with_scenario_of.building_a_specification_dataset
        {
            private int previous_concern_count;

            protected override void execute_scenario()
            {
                previous_concern_count = the_subject.Concerns.Length;
                the_subject.AddConcernFor(this.GetType());
            }

            [Test]
            public void should_not_add_duplicate_concerns()
            {
                the_subject.Concerns.Length.should_equal(previous_concern_count);
            }
        }
    }
}